<template>
	<view class="content">
		<form @submit="formSubmit">
			<view class="logo iconfont icon-morentouxiang"></view>
			
			<view class="form">
				<view class="input_wrapper">
					<input class="input" type="text" name="uname" placeholder="请输入手机号" value="13417747371"/>
				</view>
				<view class="input_wrapper">
					<input class="input" type="text" password="true" name="upass" placeholder="请输入密码" value="123456"/>
				</view>
				
				<button type="primary" form-type="submit">登录</button>
			</view>
		</form>
		
		<!-- #ifndef H5 -->
		<view class="thrid-wrapper">
			<view class="third-line">
				<view class="single-line">
					<view class="line"></view>
				</view>
				
				<view class="third-word">
					第三方帐号登录
				</view>
				
				<view class="single-line">
					<view class="line"></view>
				</view>
			</view>
			
			<view class="third-icons-wrapper">
				<!-- #ifdef APP-PLUS -->
				<text class="iconfont icon-weixin third-icon weixin" data-loginType="weixin" @click="auth"></text>
				<text class="iconfont icon-QQ1 third-icon qq" data-loginType="qq" @click="auth" style="margin-left: 30rpx;"></text>
				<text class="iconfont icon-weibo1 third-icon weibo" data-loginType="sinaweibo" @click="auth" style="margin-left:30rpx"></text>
				<!-- #endif -->
				
				<!-- #ifdef MP-WEIXIN -->
				<text class="iconfont icon-weixin third-icon weixin" data-loginType="weixin" @click="auth"></text>
				<!-- #endif -->
			</view>
			
		</view>
		<!-- #endif -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			
			async formSubmit(e) {
				const account = e.detail.value.uname.trim() ;
				const password = e.detail.value.upass.trim() ;
				
				
				const res = await this.$request({
					url:'/api/v1/user/login',
					data:{
						"account":account ,
						"password":password
					},
					header:{
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method:'POST'
				}) ;
				
	
				if(res.data.code==200) {
					var user = res.data.data ;
					
					uni.setStorageSync("token",res.header.token) ;
					
					uni.switchTab({
						url:'me'
					})
					
					
				} else if(res.data.code==401) {
					uni.showToast({
						title:res.data.message,
						duration:2000
						//image:"../../static/icons"
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	@import url("login.css");
</style>
